import java.util.ArrayList;
import java.util.Scanner;

public class ArrayList_04 {
    public static void main(String[] args) {
        ArrayList<Student_01> array = new ArrayList<>();
        addStudent(array);
        addStudent(array);
        addStudent(array);
        for (int i=0;i<array.size();i++){
            Student_01 s1 = array.get(i);
            System.out.println(s1.getName()+","+s1.getAge());

        }
    }

    public static void addStudent(ArrayList<Student_01> arrayList){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入学生姓名:");
        String name=scanner.nextLine();
        System.out.println("请输入学生年龄:");
        int age=scanner.nextInt();
        Student_01 student_01 = new Student_01();
        student_01.setName(name);
        student_01.setAge(age);
        arrayList.add(student_01);
    }
}
